<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Query\Builder as QueryBuilder;

class DbServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        QueryBuilder::macro('lists', function () {
            $data= $this->get()->toArray();
            $result = [];
            foreach ($data as $val) {
                $result[] = (array)$val;
            }
            return $result;
            // $data = $this->get()->map(function($value){
            //     return (array)$value;
            // })->toArray();
        });
    }
}
